<html>
    <head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
        <script src="http://arborjslibs.googlecode.com/svn/trunk/dev.js"></script>
        <script src="http://arborjslibs.googlecode.com/svn/trunk/graphics.js"></script>
        <script src="http://arborjslibs.googlecode.com/svn/trunk/renderer.js"></script>
    </head>
    <body>
      <canvas id="viewport" width="1400" height="800"></canvas>
      <script language="javascript" type="text/javascript">
		var sys = arbor.ParticleSystem({repulsion:400, stiffness:500,friction:.8, gravity:true});
		sys.parameters({gravity:true});
		sys.renderer = Renderer("#viewport");
	
		var servicetypes = [
			   {
				  "description" : "Interest Bearing",
				  "earlySettlementFee" : null,
				  "identifier" : "31",
				  "isDeliveryOnly" : false,
				  "isDirectDebit" : true,
				  "isRateForRiskApp" : false,
				  "isSelectEnabled" : true,
				  "isStandardEnabled" : true,
				  "manufacturerSchemeId" : null,
				  "ppiTerm" :
					 {
						"termRanges" :
						   [
							  {
								 "maxMonths" : 36,
								 "minMonths" : 36
							  }
						   ]
					 },
				  "rateType" : "RPM",
				  "rates" :
					 [
						{
						   "baseRate" : null,
						   "deferredTerm" :
							  {
								 "termRanges" :
									[
									]
							  },
						   "isSelect" : false,
						   "isTypical" : false,
						   "lprdCode" : null,
						   "lprtCode" : "00101",
						   "maxApr" : null,
						   "maxCommission" : 5.0,
						   "maxCpv" : 25000.0,
						   "maxMonths" : 60,
						   "maxRpm" : 1.0,
						   "minApr" : null,
						   "minCharge" : 20.0,
						   "minCpv" : 0.0,
						   "minDeposit" : 0.0,
						   "minMonths" : 1,
						   "minRpm" : 1.0,
						   "rateId" : 260541,
						   "term" :
							  {
								 "termRanges" :
									[
									   {
										  "maxMonths" : 6,
										  "minMonths" : 1
									   },
									   {
										  "maxMonths" : 11,
										  "minMonths" : 7
									   },
									   {
										  "maxMonths" : 23,
										  "minMonths" : 12
									   },
									   {
										  "maxMonths" : 60,
										  "minMonths" : 24
									   }
									]
							  }
						},
						{
						   "baseRate" : null,
						   "deferredTerm" :
							  {
								 "termRanges" :
									[
									]
							  },
						   "isSelect" : true,
						   "isTypical" : false,
						   "lprdCode" : null,
						   "lprtCode" : "00101",
						   "maxApr" : null,
						   "maxCommission" : 5.0,
						   "maxCpv" : 25000.0,
						   "maxMonths" : 60,
						   "maxRpm" : 1.524,
						   "minApr" : null,
						   "minCharge" : 20.0,
						   "minCpv" : 0.0,
						   "minDeposit" : 0.0,
						   "minMonths" : 1,
						   "minRpm" : 1.524,
						   "rateId" : 260582,
						   "term" :
							  {
								 "termRanges" :
									[
									   {
										  "maxMonths" : 6,
										  "minMonths" : 1
									   },
									   {
										  "maxMonths" : 11,
										  "minMonths" : 7
									   },
									   {
										  "maxMonths" : 23,
										  "minMonths" : 12
									   },
									   {
										  "maxMonths" : 60,
										  "minMonths" : 24
									   }
									]
							  }
						},
						{
						   "baseRate" : null,
						   "deferredTerm" :
							  {
								 "termRanges" :
									[
									]
							  },
						   "isSelect" : false,
						   "isTypical" : false,
						   "lprdCode" : null,
						   "lprtCode" : "00101",
						   "maxApr" : null,
						   "maxCommission" : 5.0,
						   "maxCpv" : 25000.0,
						   "maxMonths" : 60,
						   "maxRpm" : 1.6,
						   "minApr" : null,
						   "minCharge" : 20.0,
						   "minCpv" : 0.0,
						   "minDeposit" : 0.0,
						   "minMonths" : 1,
						   "minRpm" : 1.6,
						   "rateId" : 260542,
						   "term" :
							  {
								 "termRanges" :
									[
									   {
										  "maxMonths" : 6,
										  "minMonths" : 1
									   },
									   {
										  "maxMonths" : 11,
										  "minMonths" : 7
									   },
									   {
										  "maxMonths" : 23,
										  "minMonths" : 12
									   },
									   {
										  "maxMonths" : 60,
										  "minMonths" : 24
									   }
									]
							  }
						},
						{
						   "baseRate" : null,
						   "deferredTerm" :
							  {
								 "termRanges" :
									[
									]
							  },
						   "isSelect" : false,
						   "isTypical" : false,
						   "lprdCode" : null,
						   "lprtCode" : "00101",
						   "maxApr" : null,
						   "maxCommission" : 50.0,
						   "maxCpv" : 25000.0,
						   "maxMonths" : 60,
						   "maxRpm" : 1.8,
						   "minApr" : null,
						   "minCharge" : 20.0,
						   "minCpv" : 0.0,
						   "minDeposit" : 0.0,
						   "minMonths" : 1,
						   "minRpm" : 1.8,
						   "rateId" : 260543,
						   "term" :
							  {
								 "termRanges" :
									[
									   {
										  "maxMonths" : 6,
										  "minMonths" : 1
									   },
									   {
										  "maxMonths" : 11,
										  "minMonths" : 7
									   },
									   {
										  "maxMonths" : 23,
										  "minMonths" : 12
									   },
									   {
										  "maxMonths" : 60,
										  "minMonths" : 24
									   }
									]
							  }
						}
					 ],
				  "selectInstalments" :
					 [
					 ],
				  "selectQuoteDesc" : "Calculates the number of repayments from the monthly instalment selected.",
				  "selectQuoteName" : "Select Quote",
				  "serviceType" : "IBC",
				  "serviceTypeDesc" : null,
				  "standardQuoteDesc" : "Calculates the monthly instalment from the number of monthly repayments selected.",
				  "standardQuoteName" : "Standard Quote"
			   },
			   {
				  "description" : "Interest Free",
				  "earlySettlementFee" : null,
				  "identifier" : "32",
				  "isDeliveryOnly" : false,
				  "isDirectDebit" : true,
				  "isRateForRiskApp" : false,
				  "isSelectEnabled" : false,
				  "isStandardEnabled" : true,
				  "manufacturerSchemeId" : null,
				  "ppiTerm" :
					 {
						"termRanges" :
						   [
							  {
								 "maxMonths" : 36,
								 "minMonths" : 36
							  }
						   ]
					 },
				  "rateType" : "RPM",
				  "rates" :
					 [
						{
						   "baseRate" : null,
						   "deferredTerm" :
							  {
								 "termRanges" :
									[
									]
							  },
						   "isSelect" : true,
						   "isTypical" : false,
						   "lprdCode" : null,
						   "lprtCode" : "00101",
						   "maxApr" : null,
						   "maxCommission" : 5.0,
						   "maxCpv" : 25000.0,
						   "maxMonths" : 60,
						   "maxRpm" : 0.0,
						   "minApr" : null,
						   "minCharge" : 20.0,
						   "minCpv" : 0.0,
						   "minDeposit" : 10.0,
						   "minMonths" : 1,
						   "minRpm" : 0.0,
						   "rateId" : 260544,
						   "term" :
							  {
								 "termRanges" :
									[
									   {
										  "maxMonths" : 6,
										  "minMonths" : 1
									   },
									   {
										  "maxMonths" : 11,
										  "minMonths" : 7
									   },
									   {
										  "maxMonths" : 23,
										  "minMonths" : 12
									   },
									   {
										  "maxMonths" : 60,
										  "minMonths" : 24
									   }
									]
							  }
						}
					 ],
				  "selectInstalments" :
					 [
					 ],
				  "selectQuoteDesc" : "Calculates the number of repayments from the monthly instalment selected.",
				  "selectQuoteName" : "Select Quote",
				  "serviceType" : "IFC",
				  "serviceTypeDesc" : null,
				  "standardQuoteDesc" : "Calculates the monthly instalment from the number of monthly repayments selected.",
				  "standardQuoteName" : "Standard Quote"
			   },
			   {
				  "description" : "Interest Option",
				  "earlySettlementFee" : null,
				  "identifier" : "33",
				  "isDeliveryOnly" : false,
				  "isDirectDebit" : true,
				  "isRateForRiskApp" : false,
				  "isSelectEnabled" : false,
				  "isStandardEnabled" : true,
				  "manufacturerSchemeId" : null,
				  "ppiTerm" :
					 {
						"termRanges" :
						   [
							  {
								 "maxMonths" : 36,
								 "minMonths" : 36
							  }
						   ]
					 },
				  "rateType" : "RPM",
				  "rates" :
					 [
						{
						   "baseRate" : null,
						   "deferredTerm" :
							  {
								 "termRanges" :
									[
									   {
										  "maxMonths" : 6,
										  "minMonths" : 6,
										  "termType" : "InterestOption"
									   },
									   {
										  "maxMonths" : 12,
										  "minMonths" : 12,
										  "termType" : "InterestOption"
									   }
									]
							  },
						   "isSelect" : true,
						   "isTypical" : false,
						   "lprdCode" : "BFOPT2",
						   "lprtCode" : "DEFBAK",
						   "maxApr" : null,
						   "maxCommission" : 0.0,
						   "maxCpv" : 50000.0,
						   "maxMonths" : 60,
						   "maxRpm" : 1.0,
						   "minApr" : null,
						   "minCharge" : 5.0,
						   "minCpv" : 0.0,
						   "minDeposit" : 0.0,
						   "minMonths" : 6,
						   "minRpm" : 1.0,
						   "rateId" : 260491,
						   "term" :
							  {
								 "termRanges" :
									[
									   {
										  "maxMonths" : 60,
										  "minMonths" : 6
									   }
									]
							  }
						},
						{
						   "baseRate" : null,
						   "deferredTerm" :
							  {
								 "termRanges" :
									[
									]
							  },
						   "isSelect" : false,
						   "isTypical" : false,
						   "lprdCode" : null,
						   "lprtCode" : "DEFBAK",
						   "maxApr" : null,
						   "maxCommission" : 0.0,
						   "maxCpv" : 60000.0,
						   "maxMonths" : 24,
						   "maxRpm" : 3.5,
						   "minApr" : null,
						   "minCharge" : 5.0,
						   "minCpv" : 51000.0,
						   "minDeposit" : 0.0,
						   "minMonths" : 12,
						   "minRpm" : 2.5,
						   "rateId" : 260492,
						   "term" :
							  {
								 "termRanges" :
									[
									   {
										  "maxMonths" : 60,
										  "minMonths" : 6
									   }
									]
							  }
						}
					 ],
				  "selectInstalments" :
					 [
					 ],
				  "selectQuoteDesc" : "Calculates the number of repayments from the monthly instalment selected.",
				  "selectQuoteName" : "Select Quote",
				  "serviceType" : "IO",
				  "serviceTypeDesc" : null,
				  "standardQuoteDesc" : "Calculates the monthly instalment from the number of monthly repayments selected.",
				  "standardQuoteName" : "Standard Quote"
			   },
			   {
				  "description" : "Countdown Interest Free",
				  "earlySettlementFee" : null,
				  "identifier" : "34",
				  "isDeliveryOnly" : false,
				  "isDirectDebit" : true,
				  "isRateForRiskApp" : false,
				  "isSelectEnabled" : false,
				  "isStandardEnabled" : true,
				  "manufacturerSchemeId" : null,
				  "ppiTerm" :
					 {
						"termRanges" :
						   [
							  {
								 "maxMonths" : 5,
								 "minMonths" : 1
							  },
							  {
								 "maxMonths" : 60,
								 "minMonths" : 6
							  }
						   ]
					 },
				  "rateType" : "RPM",
				  "rates" :
					 [
						{
						   "baseRate" : null,
						   "deferredTerm" :
							  {
								 "termRanges" :
									[
									   {
										  "maxMonths" : 12,
										  "minMonths" : 1,
										  "termType" : "Countdown"
									   }
									]
							  },
						   "isSelect" : true,
						   "isTypical" : false,
						   "lprdCode" : "SAXONCDIBC",
						   "lprtCode" : "00101",
						   "maxApr" : null,
						   "maxCommission" : 5.0,
						   "maxCpv" : 25000.0,
						   "maxMonths" : 60,
						   "maxRpm" : 0.0,
						   "minApr" : null,
						   "minCharge" : 10.0,
						   "minCpv" : 0.0,
						   "minDeposit" : 10.0,
						   "minMonths" : 1,
						   "minRpm" : 0.0,
						   "rateId" : 260495,
						   "term" :
							  {
								 "termRanges" :
									[
									   {
										  "maxMonths" : 6,
										  "minMonths" : 1
									   },
									   {
										  "maxMonths" : 11,
										  "minMonths" : 7
									   },
									   {
										  "maxMonths" : 23,
										  "minMonths" : 12
									   },
									   {
										  "maxMonths" : 60,
										  "minMonths" : 24
									   }
									]
							  }
						}
					 ],
				  "selectInstalments" :
					 [
					 ],
				  "selectQuoteDesc" : "Calculates the number of repayments from the monthly instalment selected.",
				  "selectQuoteName" : "Select Quote",
				  "serviceType" : "CDIFC",
				  "serviceTypeDesc" : null,
				  "standardQuoteDesc" : "Calculates the monthly instalment from the number of monthly repayments selected.",
				  "standardQuoteName" : "Standard Quote"
			   },
			   {
				  "description" : "Countdown Interest Bearing",
				  "earlySettlementFee" : 29.0,
				  "identifier" : "35",
				  "isDeliveryOnly" : false,
				  "isDirectDebit" : true,
				  "isRateForRiskApp" : true,
				  "isSelectEnabled" : false,
				  "isStandardEnabled" : true,
				  "manufacturerSchemeId" : null,
				  "ppiTerm" :
					 {
						"termRanges" :
						   [
							  {
								 "maxMonths" : 5,
								 "minMonths" : 1
							  },
							  {
								 "maxMonths" : 60,
								 "minMonths" : 6
							  }
						   ]
					 },
				  "rateType" : "RPM",
				  "rates" :
					 [
						{
						   "baseRate" : null,
						   "deferredTerm" :
							  {
								 "termRanges" :
									[
									   {
										  "maxMonths" : 12,
										  "minMonths" : 1,
										  "termType" : "Countdown"
									   }
									]
							  },
						   "isSelect" : false,
						   "isTypical" : false,
						   "lprdCode" : "SAXONCDIBC",
						   "lprtCode" : "DEFBAK",
						   "maxApr" : null,
						   "maxCommission" : 5.0,
						   "maxCpv" : 25000.0,
						   "maxMonths" : 60,
						   "maxRpm" : 1.25,
						   "minApr" : null,
						   "minCharge" : 10.0,
						   "minCpv" : 0.0,
						   "minDeposit" : 10.0,
						   "minMonths" : 1,
						   "minRpm" : 1.25,
						   "rateId" : 260585,
						   "term" :
							  {
								 "termRanges" :
									[
									   {
										  "maxMonths" : 60,
										  "minMonths" : 6
									   }
									]
							  }
						},
						{
						   "baseRate" : null,
						   "deferredTerm" :
							  {
								 "termRanges" :
									[
									   {
										  "maxMonths" : 12,
										  "minMonths" : 1,
										  "termType" : "Countdown"
									   }
									]
							  },
						   "isSelect" : false,
						   "isTypical" : false,
						   "lprdCode" : "SAXONCDIBC",
						   "lprtCode" : "DEFBAK",
						   "maxApr" : null,
						   "maxCommission" : 5.0,
						   "maxCpv" : 28000.0,
						   "maxMonths" : 60,
						   "maxRpm" : 1.25,
						   "minApr" : null,
						   "minCharge" : 10.0,
						   "minCpv" : 25001.0,
						   "minDeposit" : 10.0,
						   "minMonths" : 1,
						   "minRpm" : 1.25,
						   "rateId" : 260586,
						   "term" :
							  {
								 "termRanges" :
									[
									   {
										  "maxMonths" : 60,
										  "minMonths" : 6
									   }
									]
							  }
						}
					 ],
				  "selectInstalments" :
					 [
					 ],
				  "selectQuoteDesc" : "Calculates the number of repayments from the monthly instalment selected.",
				  "selectQuoteName" : "Select Quote",
				  "serviceType" : "CDIBC",
				  "serviceTypeDesc" : null,
				  "standardQuoteDesc" : "Calculates the monthly instalment from the number of monthly repayments selected.",
				  "standardQuoteName" : "Standard Quote"
			   },
			   {
				  "description" : "Accel Payments Int Bearing",
				  "earlySettlementFee" : null,
				  "identifier" : "36",
				  "isDeliveryOnly" : false,
				  "isDirectDebit" : true,
				  "isRateForRiskApp" : false,
				  "isSelectEnabled" : false,
				  "isStandardEnabled" : true,
				  "manufacturerSchemeId" : null,
				  "ppiTerm" :
					 {
						"termRanges" :
						   [
							  {
								 "maxMonths" : 1,
								 "minMonths" : 1
							  }
						   ]
					 },
				  "rateType" : "RPM",
				  "rates" :
					 [
						{
						   "baseRate" : null,
						   "deferredTerm" :
							  {
								 "termRanges" :
									[
									]
							  },
						   "isSelect" : true,
						   "isTypical" : false,
						   "lprdCode" : null,
						   "lprtCode" : "BGASAPAPR11",
						   "maxApr" : null,
						   "maxCommission" : 16.5,
						   "maxCpv" : 50000.0,
						   "maxMonths" : 96,
						   "maxRpm" : 1.524,
						   "minApr" : null,
						   "minCharge" : 0.0,
						   "minCpv" : 0.0,
						   "minDeposit" : 0.0,
						   "minMonths" : 48,
						   "minRpm" : 1.524,
						   "rateId" : 260496,
						   "term" :
							  {
								 "termRanges" :
									[
									   {
										  "maxMonths" : 60,
										  "minMonths" : 60
									   },
									   {
										  "maxMonths" : 96,
										  "minMonths" : 96
									   }
									]
							  }
						}
					 ],
				  "selectInstalments" :
					 [
					 ],
				  "selectQuoteDesc" : "Calculates the number of repayments from the monthly instalment selected.",
				  "selectQuoteName" : "Select Quote",
				  "serviceType" : "APIBC",
				  "serviceTypeDesc" : null,
				  "standardQuoteDesc" : "Calculates the monthly instalment from the number of monthly repayments selected.",
				  "standardQuoteName" : "Standard Quote"
			   }
		]
		
		
		for(i = 0; i < servicetypes.length; i++){
			var myservice = servicetypes[i];
			sys.addNode(myservice.description,{'label':myservice.description,'color':'grey'});
			for(j = 0; j < servicetypes[i].rates.length; j++){
				var myratename = servicetypes[i].rates[j].minCpv + ' to ' + servicetypes[i].rates[j].maxCpv;				
				sys.addNode(myratename,{'label':myratename,'color':'green'});
				sys.addEdge(myservice.description, myratename,{directed:true, color:'grey'});
				for(k = 0; k < servicetypes[i].rates[j].term.termRanges.length; k++){
					var mytermname = servicetypes[i].rates[j].term.termRanges[k].minMonths + ' months to ' + servicetypes[i].rates[j].term.termRanges[k].maxMonths + ' months';
					sys.addNode(mytermname,{'label':mytermname,'color':'blue'});
					sys.addEdge(myratename, mytermname,{directed:true, color:'blue'});
				}
			}
		}
/*		
		var data = {
		nodes:
			{anja:{'label':'anja','shape':'dot','color':'grey'},
			brian:{'label':'brian','shape':'dot','color':'grey'},
			freya:{'label':'freya','shape':'dot','color':'grey'},
			andy:{'label':'andy','shape':'dot','color':'grey'}
		},
		edges:{
			anja:{andy:{color:'green',directed:true}},
			brian:{andy:{color:'red',directed:true}},
			freya:{andy:{color:'green',directed:true}},
			andy:{
				brian:{color:'green',directed:true},
				freya:{color:'red',directed:true},
				anja:{color:'red',directed:true}
				}
		}};
		sys.graft(data);
*/
//		var animals = sys.addNode('Animals',{'label':'Animals'});
//		var dog = sys.addNode('dog',{'label':'dog'});
//		var cat = sys.addNode('cat',{'label':'cat'});
//		sys.addEdge(animals, dog);
//		sys.addEdge(animals, cat);
      </script>

    </body>
</html>